﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Yunchang;
namespace AutoChess
{
    /// <summary>
    /// 进入战场 调整阶段
    /// </summary>
     class ACGameFieldState : Yunchang.FsmStateBase<AutoChessModeState>
    {
        private AutoChessManager ctr;
        public ACGameFieldState(AutoChessModeState stateType, AutoChessManager controller) : base(stateType, controller)
        {
            this.ctr = controller;
        }

        public override void Enter()
        {
            base.Enter();

            EventManager.TriggerEvent(CommonEvent.ON_PLAYER_LIST_CHANGE);

            AutoChessFieldViewCtr.Ins.ActionCtr.AddQueueAction(ActionQueueType.AdjustStart,() =>
            {
                EventManager.TriggerEvent<bool>(CommonEvent.ON_SET_SHIP_GRID_PANEL,true);
            }, 1.1f, 2);
            //调整阶段 播放特效
            AutoChessFieldViewCtr.Ins.ActionCtr.StartActionQueue(ActionQueueType.AdjustStart, null);
            ctr.CheckGameOverOnEnterState();

            Yunchang.EventManager.TriggerEvent(CommonEvent.ON_Refresh_Cache_HP);
            AutoChessPlayerCtr.Ins.CurrentPlayer.RefreshHeroNumberState();//重新计算升星，战场内的不能算
        }

        public override void Leave()
        {
            base.Leave();
            AutoChessFieldViewCtr.Ins.ActionCtr.ForceEndActionQueue(ActionQueueType.AdjustStart);
        }
    }
}
